package it.polimi.jita.cp.block.pc;

public class AsymptoticPenalty {

	private final double b;
	private final double k;
	private final double x2;

	public AsymptoticPenalty(Double x0, Double x1, Double x2) {
		this.x2 = x2;
		double l1 = x0 * (x2 - x0) / (2.0d * x1 * (x2 - x1));
		double l2 = x0 / x1;
		b = Math.log(l1) / Math.log(l2);
		k = x0 * (x2 - x0) / Math.pow(x0, b);
	}

	public double getValue(double x) {
		if (x < x2)
			return k * Math.pow(x, b) / (x2 - x);
		throw new RuntimeException();

	}
}
